﻿using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.SpreadsheetML.Excel.StyleElements
{
    [XmlRoot("tableStyles", Namespace = Constants.ExcelMain)]
    public class TableStyles : XmlSerializable
    {
        [Optional]
        [XmlAttribute("count", Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> Count { get; set; }

        [Optional]
        [XmlAttribute("defaultTableStyle", Form = XmlSchemaForm.Qualified)]
        public string DefaultTableStyle { get; set; }

        [Optional]
        [XmlAttribute("defaultPivotStyle", Form = XmlSchemaForm.Qualified)]
        public string DefaultPivotStyle { get; set; }

        [Optional]
        [XmlElement("tableStyle", Namespace = Constants.ExcelMain)]
        public XmlList<TableStyle> TableStyleList { get; set; }

        public TableStyles()
        {
            TableStyleList = new XmlList<TableStyle>();
        }

        public void AddTableStyle(TableStyle style)
        {
            if (Count == null)
            {
                Count = 0;
            }

            Count++;
            TableStyleList.Add(style);
        }
    }
}
